package com.arraylist;

import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ArrrayTest4 {
    public static void main(String[] args) {
        ArrayList<Student1> arrayList = new ArrayList<>();
        arrayList.add(new Student1("zhangsan",11));
        arrayList.add(new Student1("lisi",11));
        arrayList.add(new Student1("zhangsan",11));
        arrayList.add(new Student1("xiaohong",11));
        arrayList.add(new Student1("xiaohong",11));
        arrayList.add(new Student1("zhangsan",11));
        arrayList.add(new Student1("lisi",11));
        arrayList.add(new Student1("wangw",11));
        ArrayList<Student1> arr = new ArrayList<>();
        Iterator<Student1> iterator = arrayList.iterator();
        while (iterator.hasNext()) {
            Student1 next = iterator.next();
            if (!(arr.contains(next))) {
                arr.add(next);
            }
        }
        for (int i = 0; i < arr.size(); i++) {
            System.out.println(arrayList.get(i));
        }


    }
}
